<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>understand linux route | Matrix207&#39;s Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="路由规则理解主机的网络封包需要会根据路由规则来判断如何将封包发送出去
路由是雙向的，你必須要瞭解出去的路由與回來時的規則
常用命令
routeroute -nroute add default gw 172.16.130.1 eth2route del default gw 172.16.130.1 eth2route add -host 192.168.168.110 dev eth0route">
<meta property="og:type" content="article">
<meta property="og:title" content="understand linux route">
<meta property="og:url" content="http://yoursite.com/2015/03/11/understand-linux-route/index.html">
<meta property="og:site_name" content="Matrix207's Blog">
<meta property="og:description" content="路由规则理解主机的网络封包需要会根据路由规则来判断如何将封包发送出去
路由是雙向的，你必須要瞭解出去的路由與回來時的規則
常用命令
routeroute -nroute add default gw 172.16.130.1 eth2route del default gw 172.16.130.1 eth2route add -host 192.168.168.110 dev eth0route">
<meta property="og:updated_time" content="2016-07-17T14:33:55.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="understand linux route">
<meta name="twitter:description" content="路由规则理解主机的网络封包需要会根据路由规则来判断如何将封包发送出去
路由是雙向的，你必須要瞭解出去的路由與回來時的規則
常用命令
routeroute -nroute add default gw 172.16.130.1 eth2route del default gw 172.16.130.1 eth2route add -host 192.168.168.110 dev eth0route">
  
    <link rel="alternate" href="/atom.xml" title="Matrix207&#39;s Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
  

</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Matrix207&#39;s Blog</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="Flux RSS"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Rechercher"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-understand-linux-route" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2015/03/11/understand-linux-route/" class="article-date">
  <time datetime="2015-03-10T16:00:00.000Z" itemprop="datePublished">2015-03-11</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/linux/">linux</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      understand linux route
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="路由规则理解"><a href="#路由规则理解" class="headerlink" title="路由规则理解"></a>路由规则理解</h3><p>主机的网络封包需要会根据路由规则来判断如何将封包发送出去</p>
<p>路由是雙向的，你必須要瞭解出去的路由與回來時的規則</p>
<h3 id="常用命令"><a href="#常用命令" class="headerlink" title="常用命令"></a>常用命令</h3><ul>
<li><code>route</code><br><code>route -n</code><br><code>route add default gw 172.16.130.1 eth2</code><br><code>route del default gw 172.16.130.1 eth2</code><br><code>route add -host 192.168.168.110 dev eth0</code><br><code>route del -host 192.168.168.110 dev eth0</code><br><code>route add -net 172.16.130.0/24 gw 172.16.130.1 eth2</code><br><code>route del -net 172.16.0.0 netmask 255.255.0.0 dev eth0</code><br><code>ip route flush cache</code>  </li>
<li><code>sysctl -a |grep forward</code></li>
<li><code>sysctl -a |grep ignore</code></li>
<li><code>echo 2 &gt; /proc/sys/net/ipv4/conf/default/rp_filter</code></li>
<li><code>echo 2 &gt; /proc/sys/net/ipv4/conf/all/rp_filter</code></li>
<li><code>sysctl -p</code></li>
<li><code>vim /etc/sysctl.conf</code></li>
<li><code>traceroute www.baidu.com</code></li>
</ul>
<h3 id="相关配置文件"><a href="#相关配置文件" class="headerlink" title="相关配置文件"></a>相关配置文件</h3><pre><code>[root@localhost ~]# cat /etc/iproute2/rt_tables
#
# reserved values
#
255    local
254    main
253    default
0    unspec
#
# local
#
#1    inr.ruhep
[root@localhost ~]# sysctl -a |grep ignore
net.ipv4.conf.all.arp_ignore = 0
net.ipv4.conf.default.arp_ignore = 0
net.ipv4.conf.lo.arp_ignore = 0
net.ipv4.conf.eth0.arp_ignore = 0
net.ipv4.conf.eth1.arp_ignore = 0
net.ipv4.icmp_echo_ignore_all = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
[root@localhost ~]# cat /etc/sysctl.conf 
</code></pre><h3 id="例子"><a href="#例子" class="headerlink" title="例子"></a>例子</h3><p>如果是双网卡且设定的是同一网段IP:   </p>
<ul>
<li>eth0 : 192.168.0.100</li>
<li>eth1 : 192.168.0.200</li>
</ul>
<p>那么一般会生成这样的路由规则:  </p>
<pre><code>[root@www ~]# route -n
Kernel IP routing table
Destination     Gateway   Genmask         Flags Metric Ref   Use Iface
192.168.0.0     0.0.0.0   255.255.255.0   U     0      0       0 eth1
192.168.0.0     0.0.0.0   255.255.255.0   U     0      0       0 eth0
</code></pre><p>也就是說:  </p>
<ul>
<li>當要主動發送封包到192.168.0.0/24的網域時，都只會透過第一條規則，也就是透過eth1來傳出去!</li>
<li>在回應封包方面，不管是由eth0還是由eth1進來的網路封包，都會透過 eth1 來回傳!</li>
</ul>
<p>来自: <a href="http://linux.vbird.org/linux_server/0230router.php" target="_blank" rel="external">http://linux.vbird.org/linux_server/0230router.php</a>, [8.1.3 重複路由的問題] </p>
<h3 id="只设置一个网口IP"><a href="#只设置一个网口IP" class="headerlink" title="只设置一个网口IP"></a>只设置一个网口IP</h3><pre><code>[dennis@localhost ~]$ ssh root@172.16.60.53
root@172.16.60.53&apos;s password: 
Last login: Wed Mar 11 17:54:12 2015 from 172.16.50.39
[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.60.0     *               255.255.255.0   U     0      0        0 eth2
default         172.16.60.1     0.0.0.0         UG    0      0        0 eth2
[root@localhost ~]# ip addr
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc mq state DOWN qlen 1000
    link/ether a0:36:9f:32:b0:d0 brd ff:ff:ff:ff:ff:ff
3: eth1: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc mq state DOWN qlen 1000
    link/ether a0:36:9f:32:b0:d1 brd ff:ff:ff:ff:ff:ff
4: eth2: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:25:90:f4:6b:60 brd ff:ff:ff:ff:ff:ff
    inet 172.16.60.53/24 brd 172.16.60.255 scope global eth2
    inet6 fe80::225:90ff:fef4:6b60/64 scope link 
       valid_lft forever preferred_lft forever
5: eth3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:25:90:f4:6b:61 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::225:90ff:fef4:6b61/64 scope link 
       valid_lft forever preferred_lft forever
</code></pre><h3 id="没有问题的设定"><a href="#没有问题的设定" class="headerlink" title="没有问题的设定"></a>没有问题的设定</h3><pre><code>[dennis@localhost ~]$ ssh root@172.16.130.105
root@172.16.130.105&apos;s password: 
Permission denied, please try again.
root@172.16.130.105&apos;s password: 
Last login: Wed Mar 11 16:34:38 2015 from 172.16.50.39
[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.130.0    *               255.255.255.0   U     0      0        0 eth0
172.16.130.0    *               255.255.255.0   U     0      0        0 eth1
default         172.16.130.1    0.0.0.0         UG    0      0        0 eth1
default         172.16.130.1    0.0.0.0         UG    0      0        0 eth0
[root@localhost ~]# ping 172.16.50.39 -I eth1
PING 172.16.50.39 (172.16.50.39) from 172.16.130.106 eth1: 56(84) bytes of data.
64 bytes from 172.16.50.39: icmp_seq=1 ttl=63 time=11.7 ms
64 bytes from 172.16.50.39: icmp_seq=2 ttl=63 time=0.265 ms
^C
--- 172.16.50.39 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1568ms
rtt min/avg/max/mdev = 0.265/6.030/11.795/5.765 ms
[root@localhost ~]# ping 172.16.50.39 -I eth0
PING 172.16.50.39 (172.16.50.39) from 172.16.130.105 eth0: 56(84) bytes of data.
64 bytes from 172.16.50.39: icmp_seq=1 ttl=63 time=0.244 ms
64 bytes from 172.16.50.39: icmp_seq=2 ttl=63 time=6.12 ms
64 bytes from 172.16.50.39: icmp_seq=3 ttl=63 time=6.50 ms
^C
--- 172.16.50.39 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2414ms
rtt min/avg/max/mdev = 0.244/4.290/6.504/2.866 ms
[root@localhost ~]# ip addr
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth1: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:25:90:de:fc:13 brd ff:ff:ff:ff:ff:ff
    inet 172.16.130.106/24 scope global eth1
    inet6 fe80::225:90ff:fede:fc13/64 scope link 
       valid_lft forever preferred_lft forever
3: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:25:90:de:fc:12 brd ff:ff:ff:ff:ff:ff
    inet 172.16.130.105/24 scope global eth0
    inet6 fe80::225:90ff:fede:fc12/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# ip route show
172.16.130.0/24 dev eth0  proto kernel  scope link  src 172.16.130.105 
172.16.130.0/24 dev eth1  proto kernel  scope link  src 172.16.130.106 
default via 172.16.130.1 dev eth1 
default via 172.16.130.1 dev eth0 
</code></pre><h3 id="一台奇怪问题的机器"><a href="#一台奇怪问题的机器" class="headerlink" title="一台奇怪问题的机器"></a>一台奇怪问题的机器</h3><p>问题机器: 双网卡，IP信息 eth0:172.16.60.150 eth1:172.16.60.151 网关172.16.60.1  </p>
<p>本地主机: IP 172.16.50.39, 网关:172.16.50.1</p>
<p>本地(50.39)可以正常ssh登陆60.150  </p>
<p>但ping 172.16.60.151没有回应:</p>
<pre><code>[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:1e:67:c9:9a:f4
TYPE=Ethernet
UUID=5adb47dc-d361-43b7-a23a-f17c2ade1e2d
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=172.16.60.150
NETMASK=255.255.255.0
GATEWAY=172.16.60.1
IPV6INIT=no
USERCTL=no
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=00:1e:67:c9:9a:f5
TYPE=Ethernet
UUID=2af28c1e-abe2-4805-8c78-880ffbfc567e
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPV6INIT=no
USERCTL=no
IPADDR=172.16.60.151
NETMASK=255.255.255.0
GATEWAY=172.16.60.1
[root@localhost ~]# ip addr  
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 16436 qdisc noqueue state UNKNOWN   
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
  inet 127.0.0.1/8 scope host lo  
  inet6 ::1/128 scope host   
     valid_lft forever preferred_lft forever  
2: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc mq state UP qlen 1000  
  link/ether 00:1e:67:c9:9a:f4 brd ff:ff:ff:ff:ff:ff  
  inet 172.16.60.150/24 brd 172.16.60.255 scope global eth0  
  inet6 fe80::21e:67ff:fec9:9af4/64 scope link   
     valid_lft forever preferred_lft forever  
3: eth1: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc mq state UP qlen 1000  
  link/ether 00:1e:67:c9:9a:f5 brd ff:ff:ff:ff:ff:ff  
  inet 172.16.60.151/24 brd 172.16.60.255 scope global eth1  
  inet6 fe80::21e:67ff:fec9:9af5/64 scope link   
     valid_lft forever preferred_lft forever  
[root@localhost ~]# route  
Kernel IP routing table  
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface  
172.16.60.0     *               255.255.255.0   U     0      0        0 eth0  
172.16.60.0     *               255.255.255.0   U     0      0        0 eth1  
link-local      *               255.255.0.0     U     1002   0        0 eth0  
link-local      *               255.255.0.0     U     1003   0        0 eth1  
default         172.16.60.1     0.0.0.0         UG    0      0        0 eth0  
</code></pre><p>通过同一网段的机器(172.16.60.53)，ping 151得到的是Destination Host Unreachable  </p>
<pre><code>[dennis@localhost ~]$ ssh root@172.16.60.53
The authenticity of host &apos;172.16.60.53 (172.16.60.53)&apos; can&apos;t be established.
RSA key fingerprint is e6:b0:c1:60:53:cd:77:7c:32:e4:27:4f:01:43:5a:8a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added &apos;172.16.60.53&apos; (RSA) to the list of known hosts.
root@172.16.60.53&apos;s password: 
Last login: Fri Dec  6 04:46:04 2013
[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.60.0     *               255.255.255.0   U     0      0        0 eth2
default         172.16.60.1     0.0.0.0         UG    0      0        0 eth2
[root@localhost ~]# ping 172.16.60.151
PING 172.16.60.151 (172.16.60.151) 56(84) bytes of data.
From 172.16.60.53 icmp_seq=2 Destination Host Unreachable
From 172.16.60.53 icmp_seq=3 Destination Host Unreachable
From 172.16.60.53 icmp_seq=4 Destination Host Unreachable
^C
--- 172.16.60.151 ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4988ms
pipe 3
[root@localhost ~]# ping 172.16.60.150
PING 172.16.60.150 (172.16.60.150) 56(84) bytes of data.
64 bytes from 172.16.60.150: icmp_seq=1 ttl=64 time=0.933 ms
64 bytes from 172.16.60.150: icmp_seq=2 ttl=64 time=0.235 ms
64 bytes from 172.16.60.150: icmp_seq=3 ttl=64 time=0.223 ms
^C
--- 172.16.60.150 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2045ms
rtt min/avg/max/mdev = 0.223/0.463/0.933/0.332 ms
[root@localhost ~]# 
</code></pre><p>且从eth1(60.151)ping不通网关(172.16.60.1), ping同网段另外一台机器(60.53)开始会停顿:   </p>
<pre><code>[root@localhost ~]# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
172.16.60.1              ether   00:0f:e2:b1:c7:5d   C                     eth0
[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.60.0     *               255.255.255.0   U     0      0        0 eth0
172.16.60.0     *               255.255.255.0   U     0      0        0 eth1
link-local      *               255.255.0.0     U     1002   0        0 eth0
default         172.16.60.1     0.0.0.0         UG    0      0        0 eth0
[root@localhost ~]# ping 172.16.60.53 -I eth1
PING 172.16.60.53 (172.16.60.53) from 172.16.60.151 eth1: 56(84) bytes of data.
64 bytes from 172.16.60.53: icmp_seq=10 ttl=64 time=1.08 ms
64 bytes from 172.16.60.53: icmp_seq=11 ttl=64 time=0.228 ms
64 bytes from 172.16.60.53: icmp_seq=12 ttl=64 time=0.230 ms
64 bytes from 172.16.60.53: icmp_seq=13 ttl=64 time=0.226 ms
64 bytes from 172.16.60.53: icmp_seq=14 ttl=64 time=0.238 ms
64 bytes from 172.16.60.53: icmp_seq=15 ttl=64 time=0.225 ms
64 bytes from 172.16.60.53: icmp_seq=16 ttl=64 time=0.227 ms
^C
--- 172.16.60.53 ping statistics ---
16 packets transmitted, 7 received, 56% packet loss, time 15646ms
rtt min/avg/max/mdev = 0.225/0.351/1.085/0.299 ms
[root@localhost ~]# ping 172.16.50.39 -I eth1
PING 172.16.50.39 (172.16.50.39) from 172.16.60.151 eth1: 56(84) bytes of data.
From 172.16.60.151 icmp_seq=2 Destination Host Unreachable
From 172.16.60.151 icmp_seq=3 Destination Host Unreachable
From 172.16.60.151 icmp_seq=4 Destination Host Unreachable
From 172.16.60.151 icmp_seq=6 Destination Host Unreachable
From 172.16.60.151 icmp_seq=7 Destination Host Unreachable
From 172.16.60.151 icmp_seq=8 Destination Host Unreachable
^C
--- 172.16.50.39 ping statistics ---
8 packets transmitted, 0 received, +6 errors, 100% packet loss, time 7646ms
pipe 3
[root@localhost ~]# ping 172.16.60.1 -I eth1
PING 172.16.60.1 (172.16.60.1) from 172.16.60.151 eth1: 56(84) bytes of data.
</code></pre><p>执行<code>route add default gw 172.16.60.1 eth1</code>后，可以ping 172.16.60.151,但是150有问题了.  </p>
<p>使用ssh root@172.16.60.151登陆看到的路由信息</p>
<pre><code>[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.60.0     *               255.255.255.0   U     0      0        0 eth0
172.16.60.0     *               255.255.255.0   U     0      0        0 eth1
link-local      *               255.255.0.0     U     1002   0        0 eth0
default         172.16.60.1     0.0.0.0         UG    0      0        0 eth1
default         172.16.60.1     0.0.0.0         UG    0      0        0 eth0
[root@localhost ~]# ping 172.16.60.1 -I eth0
PING 172.16.60.1 (172.16.60.1) from 172.16.60.150 eth0: 56(84) bytes of data.
64 bytes from 172.16.60.1: icmp_seq=1 ttl=255 time=8.88 ms
64 bytes from 172.16.60.1: icmp_seq=2 ttl=255 time=6.85 ms
64 bytes from 172.16.60.1: icmp_seq=3 ttl=255 time=1.74 ms
^C
--- 172.16.60.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2142ms
rtt min/avg/max/mdev = 1.747/5.830/8.885/3.003 ms
[root@localhost ~]# ping 172.16.60.1 -I eth1
PING 172.16.60.1 (172.16.60.1) from 172.16.60.151 eth1: 56(84) bytes of data.
^C
--- 172.16.60.1 ping statistics ---
17 packets transmitted, 0 received, 100% packet loss, time 16976ms

[root@localhost ~]# ping 172.16.50.39 -I eth0
PING 172.16.50.39 (172.16.50.39) from 172.16.60.150 eth0: 56(84) bytes of data.
^C
--- 172.16.50.39 ping statistics ---
13 packets transmitted, 0 received, 100% packet loss, time 12830ms

[root@localhost ~]# ping 172.16.50.39 -I eth1
PING 172.16.50.39 (172.16.50.39) from 172.16.60.151 eth1: 56(84) bytes of data.
64 bytes from 172.16.50.39: icmp_seq=1 ttl=63 time=0.245 ms
64 bytes from 172.16.50.39: icmp_seq=2 ttl=63 time=0.296 ms
^C
--- 172.16.50.39 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1391ms
rtt min/avg/max/mdev = 0.245/0.270/0.296/0.030 ms
[root@localhost ~]# ping 172.16.60.53 -I eth0
PING 172.16.60.53 (172.16.60.53) from 172.16.60.150 eth0: 56(84) bytes of data.
64 bytes from 172.16.60.53: icmp_seq=1 ttl=64 time=0.252 ms
64 bytes from 172.16.60.53: icmp_seq=2 ttl=64 time=0.196 ms
^C
--- 172.16.60.53 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1342ms
rtt min/avg/max/mdev = 0.196/0.224/0.252/0.028 ms
[root@localhost ~]# ping 172.16.60.53 -I eth1
PING 172.16.60.53 (172.16.60.53) from 172.16.60.151 eth1: 56(84) bytes of data.
64 bytes from 172.16.60.53: icmp_seq=1 ttl=64 time=0.236 ms
64 bytes from 172.16.60.53: icmp_seq=2 ttl=64 time=0.232 ms
64 bytes from 172.16.60.53: icmp_seq=3 ttl=64 time=0.240 ms
^C
--- 172.16.60.53 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2431ms
rtt min/avg/max/mdev = 0.232/0.236/0.240/0.003 ms
</code></pre><p><strong>这时候应该怎么设置route呢?</strong></p>
<p>可是没有看出哪里有问题，发往172.16.60.XX ip段的都从eth0走，其他IP段的从eth0发送给默认网关172.16.60.1</p>
<h3 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h3><ul>
<li><a href="http://linux.vbird.org/linux_server/0150detect_network.php" target="_blank" rel="external">Linux 網路偵錯</a></li>
<li><a href="http://my.oschina.net/jing31/blog/6611" target="_blank" rel="external">Linux双网卡设置IP属于同一网段的问题</a></li>
<li><a href="http://os.51cto.com/art/201205/339800.htm" target="_blank" rel="external">Linux系统IP路由的工作原理</a></li>
<li><a href="http://linux.vbird.org/linux_server/0230router.php" target="_blank" rel="external">路由觀念與路由器設定</a></li>
<li><a href="http://my.oschina.net/guol/blog/156607" target="_blank" rel="external">Linux策略路由</a></li>
<li><a href="http://yuangeqingtian.blog.51cto.com/6994701/1218946" target="_blank" rel="external">linux下路由表详解</a></li>
<li><a href="http://www.centoscn.com/CentOS/Intermediate/2013/0915/1633.html" target="_blank" rel="external">CentOS双网卡策略路由测试</a></li>
<li><a href="http://my.oschina.net/7shell/blog/308887" target="_blank" rel="external">Linux双网卡(内外网)同时使用路由设置</a></li>
<li><a href="http://forum.ubuntu.org.cn/viewtopic.php?f=54&amp;t=327616" target="_blank" rel="external">linux双网卡实现局域网跨网段访问</a></li>
<li><a href="http://blog.csdn.net/zhuying_linux/article/details/6770730" target="_blank" rel="external">ping工作原理</a></li>
<li><a href="http://stackoverflow.com/questions/18536796/icmp-request-received-but-doesnt-reply" target="_blank" rel="external">icmp request received, but doesn’t reply</a></li>
<li><a href="https://access.redhat.com/solutions/53031" target="_blank" rel="external">https://access.redhat.com/solutions/53031</a></li>
<li><a href="http://fengyun.blog.51cto.com/532912/608713" target="_blank" rel="external">杂谈icmp</a></li>
<li><a href="http://leo0216.blog.51cto.com/188904/84863" target="_blank" rel="external">LINUX ROUTE配置小记</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2015/03/11/understand-linux-route/" data-id="ciqqpe1sg00c2nmpv4re9r716" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/linux/">linux</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2015/03/12/how-to-detect-the-internal-network-topology-of-company/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Récent</strong>
      <div class="article-nav-title">
        
          how to detect the internal network topology of company
        
      </div>
    </a>
  
  
    <a href="/2015/02/09/message-queue-middleware/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Ancien</strong>
      <div class="article-nav-title">Message Queue Middleware</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Catégories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/blog/">blog</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/database/">database</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/english/">english</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/kernel/">kernel</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/language/">language</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/linux/">linux</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/math/">math</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/network/">network</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/others/">others</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/person/">person</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/program/">program</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/source/">source</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/storage/">storage</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/tools/">tools</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/windows/">windows</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Mot-clés</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/FAQ/">FAQ</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/IRC/">IRC</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Translation/">Translation</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/android/">android</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/api/">api</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/assembly/">assembly</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/awk/">awk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/batch/">batch</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/blog/">blog</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/book/">book</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c++</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cache/">cache</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/crash/">crash</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/database/">database</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/debug/">debug</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dot/">dot</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/driver/">driver</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/emacs/">emacs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/exploit/">exploit</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/file-system/">file system</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/filesystem/">filesystem</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/flowchart/">flowchart</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gcc/">gcc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/google/">google</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/graphviz/">graphviz</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hosts/">hosts</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/iscsi/">iscsi</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javascript/">javascript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/job/">job</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/json/">json</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/kernel/">kernel</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lisp/">lisp</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lua/">lua</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/makefile/">makefile</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/malloc/">malloc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/math/">math</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/maxima/">maxima</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memory/">memory</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memory-overflow/">memory overflow</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mtrace/">mtrace</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/netdisk/">netdisk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/network/">network</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/others/">others</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pandoc/">pandoc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/performance/">performance</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/person/">person</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/">protobuf</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rsync/">rsync</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sed/">sed</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/shell/">shell</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/skype/">skype</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sms/">sms</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/source/">source</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ssh/">ssh</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/stack/">stack</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/storage/">storage</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/study/">study</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/svn/">svn</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sync/">sync</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/test/">test</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/time/">time</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/tools/">tools</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/valgrind/">valgrind</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vi/">vi</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vim/">vim</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/virtual/">virtual</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wget/">wget</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/windows/">windows</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wireshark/">wireshark</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/write/">write</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/xml/">xml</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Nuage de mot-clés</h3>
    <div class="widget tagcloud">
      <a href="/tags/FAQ/" style="font-size: 10px;">FAQ</a> <a href="/tags/IRC/" style="font-size: 10px;">IRC</a> <a href="/tags/Translation/" style="font-size: 13px;">Translation</a> <a href="/tags/android/" style="font-size: 10px;">android</a> <a href="/tags/api/" style="font-size: 10px;">api</a> <a href="/tags/assembly/" style="font-size: 10px;">assembly</a> <a href="/tags/awk/" style="font-size: 11px;">awk</a> <a href="/tags/batch/" style="font-size: 14px;">batch</a> <a href="/tags/blog/" style="font-size: 10px;">blog</a> <a href="/tags/book/" style="font-size: 10px;">book</a> <a href="/tags/c/" style="font-size: 16px;">c</a> <a href="/tags/c/" style="font-size: 19px;">c++</a> <a href="/tags/cache/" style="font-size: 10px;">cache</a> <a href="/tags/crash/" style="font-size: 10px;">crash</a> <a href="/tags/database/" style="font-size: 17px;">database</a> <a href="/tags/debug/" style="font-size: 12px;">debug</a> <a href="/tags/dot/" style="font-size: 10px;">dot</a> <a href="/tags/driver/" style="font-size: 10px;">driver</a> <a href="/tags/emacs/" style="font-size: 11px;">emacs</a> <a href="/tags/exploit/" style="font-size: 10px;">exploit</a> <a href="/tags/file-system/" style="font-size: 10px;">file system</a> <a href="/tags/filesystem/" style="font-size: 12px;">filesystem</a> <a href="/tags/flowchart/" style="font-size: 10px;">flowchart</a> <a href="/tags/gcc/" style="font-size: 10px;">gcc</a> <a href="/tags/git/" style="font-size: 12px;">git</a> <a href="/tags/google/" style="font-size: 11px;">google</a> <a href="/tags/graphviz/" style="font-size: 11px;">graphviz</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a> <a href="/tags/hosts/" style="font-size: 10px;">hosts</a> <a href="/tags/iscsi/" style="font-size: 14px;">iscsi</a> <a href="/tags/java/" style="font-size: 10px;">java</a> <a href="/tags/javascript/" style="font-size: 10px;">javascript</a> <a href="/tags/job/" style="font-size: 10px;">job</a> <a href="/tags/json/" style="font-size: 10px;">json</a> <a href="/tags/kernel/" style="font-size: 14px;">kernel</a> <a href="/tags/linux/" style="font-size: 14px;">linux</a> <a href="/tags/lisp/" style="font-size: 10px;">lisp</a> <a href="/tags/lua/" style="font-size: 10px;">lua</a> <a href="/tags/makefile/" style="font-size: 10px;">makefile</a> <a href="/tags/malloc/" style="font-size: 10px;">malloc</a> <a href="/tags/math/" style="font-size: 11px;">math</a> <a href="/tags/maxima/" style="font-size: 10px;">maxima</a> <a href="/tags/memory/" style="font-size: 11px;">memory</a> <a href="/tags/memory-overflow/" style="font-size: 10px;">memory overflow</a> <a href="/tags/mtrace/" style="font-size: 10px;">mtrace</a> <a href="/tags/netdisk/" style="font-size: 10px;">netdisk</a> <a href="/tags/network/" style="font-size: 20px;">network</a> <a href="/tags/others/" style="font-size: 18px;">others</a> <a href="/tags/pandoc/" style="font-size: 10px;">pandoc</a> <a href="/tags/performance/" style="font-size: 16px;">performance</a> <a href="/tags/person/" style="font-size: 11px;">person</a> <a href="/tags/protobuf/" style="font-size: 11px;">protobuf</a> <a href="/tags/python/" style="font-size: 10px;">python</a> <a href="/tags/rsync/" style="font-size: 10px;">rsync</a> <a href="/tags/sed/" style="font-size: 11px;">sed</a> <a href="/tags/shell/" style="font-size: 15px;">shell</a> <a href="/tags/skype/" style="font-size: 11px;">skype</a> <a href="/tags/sms/" style="font-size: 10px;">sms</a> <a href="/tags/source/" style="font-size: 11px;">source</a> <a href="/tags/ssh/" style="font-size: 10px;">ssh</a> <a href="/tags/stack/" style="font-size: 10px;">stack</a> <a href="/tags/storage/" style="font-size: 15px;">storage</a> <a href="/tags/study/" style="font-size: 10px;">study</a> <a href="/tags/svn/" style="font-size: 11px;">svn</a> <a href="/tags/sync/" style="font-size: 10px;">sync</a> <a href="/tags/test/" style="font-size: 11px;">test</a> <a href="/tags/time/" style="font-size: 10px;">time</a> <a href="/tags/tools/" style="font-size: 16px;">tools</a> <a href="/tags/valgrind/" style="font-size: 10px;">valgrind</a> <a href="/tags/vi/" style="font-size: 10px;">vi</a> <a href="/tags/vim/" style="font-size: 14px;">vim</a> <a href="/tags/virtual/" style="font-size: 11px;">virtual</a> <a href="/tags/wget/" style="font-size: 10px;">wget</a> <a href="/tags/windows/" style="font-size: 11px;">windows</a> <a href="/tags/wireshark/" style="font-size: 10px;">wireshark</a> <a href="/tags/write/" style="font-size: 13px;">write</a> <a href="/tags/xml/" style="font-size: 10px;">xml</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">July 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/">April 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">March 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/02/">February 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">November 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/10/">October 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/09/">September 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/08/">August 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/07/">July 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/06/">June 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/03/">March 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/02/">February 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/01/">January 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/12/">December 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/11/">November 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/09/">September 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/08/">August 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/07/">July 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/06/">June 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/05/">May 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/04/">April 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/03/">March 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/11/">November 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/10/">October 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/09/">September 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/08/">August 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/07/">July 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/06/">June 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/05/">May 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/04/">April 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/03/">March 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/02/">February 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/01/">January 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/12/">December 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/09/">September 2012</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Articles récents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/07/17/how-to-implement-malloc/">如何实现一个malloc</a>
          </li>
        
          <li>
            <a href="/2016/07/17/study-grep-more/">grep工作原理</a>
          </li>
        
          <li>
            <a href="/2016/07/17/2016-04-13-malloc/">malloc</a>
          </li>
        
          <li>
            <a href="/2016/04/27/include-what-you-use/">使用IWYU整理头文件引用</a>
          </li>
        
          <li>
            <a href="/2016/04/24/understand-gcc-assembly-output/">understand gcc assembly output</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2016 Matrix207<br>
      Propulsé by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>

  </div>
</body>
</html>